import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import _inherits from "@babel/runtime/helpers/esm/inherits";
import _createSuper from "@babel/runtime/helpers/esm/createSuper";
import _applyDecoratedDescriptor from "@babel/runtime/helpers/esm/applyDecoratedDescriptor";

var _dec, _dec2, _class;

/**
 * SearchForm
 * @date 2019-08-21
 */
import React from 'react';
import moment from 'moment';
import { Form, Button, DatePicker, Row, Col } from 'antd';
import { Bind } from 'lodash-decorators';
import intl from 'utils/intl';
import { SEARCH_FORM_CLASSNAME, SEARCH_COL_CLASSNAME, SEARCH_FORM_ROW_LAYOUT, FORM_COL_4_LAYOUT, SEARCH_FORM_ITEM_LAYOUT } from 'utils/constants';
import { getDateTimeFormat } from 'utils/utils';
var SearchForm = (_dec = Bind(), _dec2 = Bind(), (_class = /*#__PURE__*/function (_React$Component) {
  _inherits(SearchForm, _React$Component);

  var _super = _createSuper(SearchForm);

  function SearchForm() {
    _classCallCheck(this, SearchForm);

    return _super.apply(this, arguments);
  }

  _createClass(SearchForm, [{
    key: "handleResetBtnClick",
    value: function handleResetBtnClick(e) {
      e.preventDefault();
      var form = this.props.form;
      form.resetFields();
    }
  }, {
    key: "handleSearchBtnClick",
    value: function handleSearchBtnClick(e) {
      e.preventDefault();
      var onSearch = this.props.onSearch;
      onSearch();
    }
  }, {
    key: "render",
    value: function render() {
      var form = this.props.form;
      var dateTimeFormat = getDateTimeFormat();
      return /*#__PURE__*/React.createElement(Form, {
        className: SEARCH_FORM_CLASSNAME
      }, /*#__PURE__*/React.createElement(Row, SEARCH_FORM_ROW_LAYOUT, /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('cimp.commentImport.model.commentImport.creationDateFrom').d('创建日期从')
      }), form.getFieldDecorator('creationDateFrom')( /*#__PURE__*/React.createElement(DatePicker, {
        showTime: true,
        placeholder: "",
        format: dateTimeFormat,
        disabledDate: function disabledDate(currentDate) {
          return form.getFieldValue('creationDateTo') && moment(form.getFieldValue('creationDateTo')).isBefore(currentDate);
        }
      })))), /*#__PURE__*/React.createElement(Col, FORM_COL_4_LAYOUT, /*#__PURE__*/React.createElement(Form.Item, Object.assign({}, SEARCH_FORM_ITEM_LAYOUT, {
        label: intl.get('cimp.commentImport.model.commentImport.creationDateTo').d('创建日期至')
      }), form.getFieldDecorator('creationDateTo')( /*#__PURE__*/React.createElement(DatePicker, {
        showTime: true,
        placeholder: "",
        format: dateTimeFormat,
        disabledDate: function disabledDate(currentDate) {
          return form.getFieldValue('creationDateFrom') && moment(form.getFieldValue('creationDateFrom')).isAfter(currentDate);
        }
      })))), /*#__PURE__*/React.createElement(Col, Object.assign({}, FORM_COL_4_LAYOUT, {
        className: SEARCH_COL_CLASSNAME
      }), /*#__PURE__*/React.createElement(Form.Item, null, /*#__PURE__*/React.createElement(Button, {
        onClick: this.handleResetBtnClick
      }, intl.get('cpaas.common.button.reset').d('重置')), /*#__PURE__*/React.createElement(Button, {
        htmlType: "submit",
        type: "primary",
        onClick: this.handleSearchBtnClick
      }, intl.get('cpaas.common.button.search').d('查询'))))));
    }
  }]);

  return SearchForm;
}(React.Component), (_applyDecoratedDescriptor(_class.prototype, "handleResetBtnClick", [_dec], Object.getOwnPropertyDescriptor(_class.prototype, "handleResetBtnClick"), _class.prototype), _applyDecoratedDescriptor(_class.prototype, "handleSearchBtnClick", [_dec2], Object.getOwnPropertyDescriptor(_class.prototype, "handleSearchBtnClick"), _class.prototype)), _class));
export default Form.create({
  fieldNameProp: null
})(SearchForm);